package org.pjsip.utils;

import android.content.Context;

import com.blankj.utilcode.util.GsonUtils;
import com.blankj.utilcode.util.SPUtils;
import com.blankj.utilcode.util.StringUtils;
import com.gwf.llsipproject.Utils;

import org.pjsip.bean.SeatInfo;

/**
 * author : GWFan
 * time   : 1/20/21 2:42 PM
 * desc   :
 */

public class LocalStorageUtils {
    private static SPUtils instance;

    public static SPUtils getSPUtils() {
        if (instance == null) {
            synchronized (Utils.class) {
                if (instance == null) {
                    instance = SPUtils.getInstance("my_sip_demo", Context.MODE_PRIVATE);
                }
            }
        }
        return instance;
    }

    /**
     * 坐席信息
     *
     * @param seatInfo
     */
    public static void setSeatInfo(SeatInfo seatInfo) {
        getSPUtils().put("seatInfo", GsonUtils.toJson(seatInfo));
    }

    public static SeatInfo getSeatInfo() {
        String json = getSPUtils().getString("seatInfo");
        if (StringUtils.isEmpty(json)) {
            return null;
        }
        return GsonUtils.fromJson(json, SeatInfo.class);
    }
}
